using System;
using System.Collections;
using UnityEngine;

public class ServerLog : MonoBehaviour
{
	public static ServerLog instance;

	private string log;

	private string headerLog;

	private Queue myLogQueue = new Queue();

	public float linesize = 20f;

	private void Start()
	{
		instance = this;
	}

	public void Log(string text)
	{
		myLogQueue.Enqueue(text);
		log = string.Empty;
		IEnumerator enumerator = myLogQueue.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				string str = (string)enumerator.Current;
				log = log + str + "\n";
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
		if ((float)myLogQueue.Count > (float)Screen.height / linesize - 2f)
		{
			myLogQueue.Dequeue();
		}
	}

	private void OnGUI()
	{
		if (NetworkTracer.instance != null)
		{
			headerLog = NetworkTracer.instance.Detail;
		}
		GUILayout.Label(headerLog + "\n" + log);
	}
}
